﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Bussiness.Manager;
using Bussiness.Entity;
public partial class News_Control_Detail : System.Web.UI.UserControl
{

    public Guid IdNewsInfo
    {
        get { return Guid.Empty; } //!string.IsNullOrEmpty(Request["textid"]) ? new Guid(Request["textid"]) : Guid.Empty; }
    }

    public Int32 Int_id
    { get { return !string.IsNullOrEmpty(Request["textid"]) ? Int32.Parse(Request["textid"]) : -1; } }

    public Guid CatId = Guid.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        Pager1.ChangePage += new EventHandler(Pager1_ChangePage);
        LoadData();
        LoadNewsListByCat();
    }

    void Pager1_ChangePage(object sender, EventArgs e)
    {
        LoadData();
        LoadNewsListByCat();
    }

    void LoadData()
    {
        if (Int_id != -1)
        {
            DataTable dtNewsDetail = CmsNewsInfosManager.CreateInstant().getNewsDetailByIntId(Int_id);
            if (dtNewsDetail.Rows.Count >= 0)
            {
                Pager1.DataSource = dtNewsDetail.DefaultView;
                Pager1.BindToControl = rep;
                rep.DataSource = dtNewsDetail;
                rep.DataBind();

                CatId = new Guid(dtNewsDetail.Rows[0]["CategoryId"].ToString());
            }
        }
    }

    void LoadNewsListByCat()
    {
        DataTable dtNewsList = CmsNewsManager.CreateInstant().getNewsListRelation(CatId,Int_id);
        if (dtNewsList.Rows.Count >= 0)
        {
            //Pager1.DataSource = dtNewsList.DefaultView;
            //Pager1.BindToControl = rep;
            rep1.DataSource = dtNewsList;
            rep1.DataBind();
        }
    }
}
